/**
 * @(#)StringUtil.java 2011-9-6
 * 
 * Copyright 2000-2011 by ChinanetCenter Corporation.
 *
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * ChinanetCenter Corporation ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with ChinanetCenter.
 * 
 */

package com.szf.util;

import org.apache.commons.lang.StringUtils;

public abstract class StringUtil extends StringUtils {

	/**
	 * 转换成sql in的查询条件
	 * 
	 * @param object
	 * @return
	 */
	public static String getInString(Object object) {
		ValidateUtil.notNull(object, "object不能为空");
		StringBuffer bf = new StringBuffer();
		String str = object.toString();
		ValidateUtil.notEmpty(str, "str不能为空");
		if (str.indexOf(",") == -1) {
			return "'" + str + "'";
		}
		String[] ips = str.split(",");
		for (int i = 0; i < ips.length; i++) {
			String ip = ips[i];
			if (StringUtils.isEmpty(ip)) {
				continue;
			}
			if (i == ips.length - 1) {
				bf.append("'" + ip + "'");
			}
			else {
				bf.append("'" + ip + "',");
			}
		}
		return  bf.toString();
	}

}
